<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 普通JS引入 -->
    <!-- <script src="../js/axios.min.js"></script>
    <script>
        console.log(axios);  //全局的
    </script> -->
</head>

<body>
    <button class="get">get</button>
    <button class="post">post</button>
</body>
<script type="module">
    import "../js/axios.min.js";
    console.log(axios);


    var getBtn = document.getElementsByClassName("get")[0];
    var postBtn = document.getElementsByClassName("post")[0];

    var baseURL = "http://43.138.81.225/demo/php/";

    getBtn.onclick = function () {
        var wd = ""; //全局变量  记录搜索的关键词   "" => 默认查询所有数据
        var col = "id"; // 全局变量  按哪个数据排序  默认按id排序
        var type = "asc"; //  全局变量  排序方式   默认升序
        var page = 1;   // 全局变量  记录页码(默认显示第一页)
        var size = 5;   // 全局变量  记录每页显示几条数据

        // http://43.138.81.225/demo/php/searchGoodsOrderLimit.php

        axios({
            method: "get",
            baseURL,
            url: "/searchGoodsOrderLimit.php",
            // 
            params: {
                wd, col, type, page, size
            },
            // responseType: 'json',
        }).then(res => {
            console.log("请求成功", res);
            console.log("请求成功:data", res.data);
        })

    }


    postBtn.onclick = function () {
        var account = "a123123";
        var pwd = "123123";

        // http://43.138.81.225/demo/php/login_account.php


        axios({
            method: "post",
            baseURL,
            url: "login_account.php",
            data: {
                account,
                pwd
            },
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            }
            // responseType: 'json',
        }).then(res => {
            console.log("请求成功", res);
            console.log("请求成功:data", res.data);
        })

    }

</script>

</html>